<?php

include_once('../@base/portal.php');
// include_once('../@base/logfile.php');
// include_once('../@base/database.php');
include_once('../login/login.php');

if ($post) {
    output(insertData($post->user, $post->data));
}


function insertData($user, $data)
{
    $loginData = login($user->name, $user->passwd);
    if ($loginData['userbase']['level'] <= 0) {
        return array('status' => -1);
    }
    $submitTime = date("Y-m-d H:i:s");
    $sql = "INSERT INTO oprec_rectify_record (number, clientName, clientGroup, clientOffice, clientRank, seat, sector, partners, attributes, eventTime, category, item, value, description, userName, userGroup, userOffice, level, type, SubmitTime, status) VALUES (null,'{$data->clientName}','{$data->clientGroup}','{$data->clientOffice}','{$data->clientRank}','{$data->seat}','{$data->sector}','{$data->partners}','{$data->attributes}','{$data->eventTime}','{$data->category}','{$data->item}','{$data->value}','{$data->description}','{$data->userName}','{$data->userGroup}','{$data->userOffice}','{$data->level}','{$data->type}','{$submitTime}',0)";
    if (conf('debug')) logfile('LOGIN_SQL', $sql);
    $res = exec_sql($sql);
    return array('status' => 0, 'content' => $res);
}

/* 
        ViolationsRectifying

        INSERT INTO oprec_rectify_record(number, clientName, clientGroup, clientOffice, seat, sector, partners, attributes, eventTime, category, item, description, userName, userGroup, userOffice, SubmitTime, status) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5],[value-6],[value-7],[value-8],[value-9],[value-10],[value-11],[value-12],[value-13],[value-14],[value-15],[value-16],[value-17])

        "data": {
            "clientName": "",
            "clientOffice": "",
            "clientGroup": "",
            "seat": "",
            "sector": "",
            "partners": "",
            "attributes": "",
            "eventTime": "",
            "category": "",
            "item": "",
            "description": "",
            "userName": "",
            "userGroup": "",
            "userOffice": ""
        }

    */